﻿using System;
using DevFramework.Core.DataAccess.NHibernate;
using DevFramework.Business.Abstract;
using DevFramework.Business.Concrete.Managers;
using DevFramework.DataLayer.Abstract;
using DevFramework.DataLayer.Concrete.EntityFramework;
using DevFramework.DataLayer.Concrete.NHibernate;
using DevFramework.DataLayer.Concrete.NHibernate.Helper;
using DevFramework.Entities.Concrete;
using DevFramework.Business.Abstract;
using Ninject.Activation;
using Ninject.Modules;
using Ninject.Extensions.Conventions;

namespace DevFramework.Business.DependencyResolvers.Ninject
{
    public class BusinessModule : NinjectModule
    {
        public override void Load()
        {
            Bind<IProductService>().To<ProductManager>().InSingletonScope();
            Bind<ICategoryService>().To<CategoryManager>().InSingletonScope();
            Bind<ILanguageService>().To<LanguageManager>().InSingletonScope();
            Bind<ILanguageWordService>().To<LanguageWordManager>().InSingletonScope();
            Bind<IVProductService>().To<VProductManager>().InSingletonScope();
            Bind<IOrderSalesService>().To<OrderSalesManager>().InSingletonScope();
            Bind<IUserService>().To<UserManager>().InSingletonScope();

            Bind<IProductDal>().To<NhProductDal>().InSingletonScope();
            Bind<ICategoryDal>().To<NhCategoryDal>().InSingletonScope();
            Bind<ILanguageDal>().To<NhLanguageDal>().InSingletonScope();
            Bind<ILanguageWordDal>().To<NhLanguageWordDal>().InSingletonScope();
            Bind<IVProductDal>().To<NhVProductDal>().InSingletonScope();
            Bind<IOrderSalesDal>().To<NhOrderSalesDal>().InSingletonScope();
            Bind<IUserDal>().To<NhUserDal>().InSingletonScope();

            //this.Bind(x =>
            //{
            //    x.FromThisAssembly()
            //        .SelectAllClasses().InNamespaceOf<ProductManager>()
            //        .BindAllInterfaces()
            //        .Configure(t => t.InSingletonScope());

            //    x.FromAssemblyContaining<NhProductDal>()
            //        .Select(t => t.Namespace == "DevFramework.DataLayer.Concrete.NHibernate")
            //        .BindDefaultInterfaces()
            //        .Configure(t => t.InSingletonScope());
            //});

            Bind<NHibernateHelper>().To<SqlNHibernateHelper>().InSingletonScope();
        }
    }
}
